﻿using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Logging;
using System;
using NLog;
using NLog.Extensions.Logging;
namespace ZeusCore.Performance.Test
{
    using Zeus.Mvc;
    public class MvcStartup
    {
        private ZeusMvcOptions _zeusMvcOptions;

        public MvcStartup()
        {
            _zeusMvcOptions = new ZeusMvcOptions(typeof(ConsoleHttpContextLogger));
        }

        public void ConfigureServices(IServiceCollection services)
        {

            //for (var i = 0; i < services.Count; i++)
            //{
            //    var item = services[i];

            //    Type type = item.ServiceType ?? item.ImplementationType ?? item.ImplementationInstance.GetType();
            //    Console.WriteLine(type.Name);
            //}

            //services.AddMvcCore().AddJsonFormatters(j => {
            //    j.Formatting = Formatting.Indented;
            //    j.DateFormatString = "yyyMMdd HH:mm:ss";
            //});
            //services.AddTransient<IZeusResultExecutor, DefaultZeusResultExecutor>();
            services.AddMvcCore();
            services.UseZeus(_zeusMvcOptions);



        }

        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {

            app.UserZeus(_zeusMvcOptions);
            app.UseMvc();
            loggerFactory.AddNLog();

            //var defaultZeusResultExecutor = app.ApplicationServices.GetRequiredService<IZeusResultExecutor>();

            //var httpRequestStreamReaderFactory = app.ApplicationServices.GetRequiredService<IHttpRequestStreamReaderFactory>();
        }
    }
}
